--我这里使用的是oracle数据库，其他数据库可以自己修改sql语句。数据库信息：applicationContext.xml，里面有sqlserver和oracle、mysql的配置。
--1、创建序列
drop SEQUENCE  t_user_id;
--创建序列
create sequence  t_user_id  minvalue 1 maxvalue 999999999999999999999999999 increment by 1 start with 1 cache 20 noorder  nocycle ;
--查询下一个序列
select t_user_id.nextval from dual;
--2、创建触发器
CREATE
  OR REPLACE TRIGGER t_user_Trigger BEFORE INSERT
    ON
    t_user FOR EACH ROW BEGIN SELECT
      t_user_id.nextval INTO
        :new.user_id
      FROM
        dual;
END;
--3、创建表
CREATE TABLE t_user(
  user_id INT  PRIMARY KEY ,
  user_name VARCHAR2(30),
  credits INT,
  password VARCHAR2(32),
  last_visit VARCHAR2(19),
  last_ip VARCHAR2(23)
)

CREATE TABLE t_login_log(
  login_log_id INT PRIMARY KEY ,
  user_id INT,
  ip VARCHAR2(23),
  login_datetime VARCHAR2(19)
)

INSERT INTO t_user (user_name,password)VALUES('sysadmin','123456');
SELECT   *FROM  t_user;


#mysql环境
DROP DATABASE IF EXISTS sampledb;
CREATE DATABASE sampledb DEFAULT  CHARACTER SET utf8;
USE sampledb;

# user table
CREATE TABLE t_user(
  user_id INT AUTO_INCREMENT PRIMARY KEY ,
  user_name VARCHAR(30),
  credits INT,
  password VARCHAR(32),
  last_visit datetime,
  last_ip VARCHAR(23)
)ENGINE=InnoDB;

#  login log table
CREATE TABLE t_login_log(
  login_log_id INT AUTO_INCREMENT PRIMARY KEY ,
  user_id INT,
  ip VARCHAR(23),
  login_datetime datetime
)ENGINE=InnoDB;


# DATA

INSERT INTO t_user (user_name,password)VALUES('admin','123456');